﻿using Microsoft.AspNetCore.Mvc;

namespace AspNetCoreWebApi.Controllers
{
    [Route("api/String")]
    [ApiController]
    public class StringController
    {
        //1、创建字符串集合
        public static List<string> Strings = new List<string>();

        // 3、获取字符串
        [HttpGet]
        public List<string> GetString()
        {
            return Strings;
        }

        // 3、获取字符串
        //[HttpGet]
        //public List<string> xxGetStringxxx()
        //{
        //    return Strings;
        //}

        [HttpPost]
        public List<string> PostString()
        {
            Strings.Add("webapi字符串");
            return Strings;
        }

        /// <summary>
        /// 4、修改字符串
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public List<string> UpdateString()
        {
            Strings.RemoveAt(0);
            Strings.Add("webapi字符串修改");
            return Strings;
        }

        /// <summary>
        /// 4、删除字符串
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public List<string> DeleteString()
        {
            Strings.RemoveAt(0);
            return Strings;
        }
    }
}
